Use of FrozensetsΒΆ
S1.isdisjoint(S2)
S1.difference(S2)
Use of Frozensets.
S1 = frozenset([1, 2, 3, 4, 5])
S2 = frozenset([3, 4, 5, 6, 7])
# Use isdisjoint().
# Return True if the set has no elements in common with other.
print(S1.isdisjoint(S2)) # False
# Use difference().
# Return a new set with elements in the set that are not in the others.
print(S1.difference(S2)) # frozenset({1, 2})
# New set with elements from both S1 and S2
print(S1 | S2) # frozenset({1, 2, 3, 4, 5, 6, 7})